---------------------------------------------------------------------------------------------------------------------------
      name:  <unnamed>
       log:  /Users/Jeff/Dropbox/TermLimits/Replication/Models/IndexEmpirical/Conditional/AdditionalControls/PredictedValue
> s.log
  log type:  text
 opened on:  12 Nov 2016, 20:58:49

. cd "/Users/Jeff/Dropbox/TermLimits/Replication/Models/IndexEmpirical/Conditional/AdditionalControls/";
/Users/Jeff/Dropbox/TermLimits/Replication/Models/IndexEmpirical/Conditional/AdditionalControls

. **************************************************************;
. *Author: Jeff Carter                                         *;
. *Date: Wednesday, December 3, 2014                              *;
. *Purpose: Simulating Predictions                *;
. **************************************************************;
. *********************************;
. **      Peace to War            *;
. *********************************;
. use "/Users/Jeff/Dropbox/TermLimits/Replication/Models/IndexEmpirical/Conditional/AdditionalControls/SimData.dta";

. postutil clear;

. postfile mypost prob_hat0 lo0 hi0 prob_hat1 lo1 hi1 diff_hat0 diff_lo0 diff_hi0
>                 prob_hat01 lo01 hi01 prob_hat11 lo11 hi11 diff_hat01 diff_lo01 diff_hi01
>                 delta_hat delta_lo delta_hi using PredictedValues, replace;
(note: file PredictedValues.dta not found)

. noisily display "start";
start

. local a=-1 ;

. while `a' < 4 { ;
  2. {;
  3. *termlimited milservice termlimited_mil  parliament civwar  rgdp96pc_gle  growth_gle;
. *majpow numbord mm time_mid time2_mid time_3mid;
.  scalar h_Accountable =   0  ;
  4. scalar h_LameDuck= 1  ;
  5. scalar h_Civilian = 0;
  6. scalar h_Military = 1;
  7. scalar h_Constant = 1;
  8. scalar h_Parliament = 0;
  9. scalar h_CivilWar = 0;
 10. scalar h_GDPpc =  12589.35;
 11. scalar h_Growth = 3.453132;
 12. scalar h_MajorPower = 0;
 13. scalar h_Borders = 2;
 14. scalar h_Mobilization =  -.0008714 ;
 15. scalar h_Time = 5;
 16.  scalar h_Female = 0;
 17.  scalar h_Rivalry = 0 ;
 18. generate x_betahat0 = MG_b1*h_Accountable
>     + MG_b2*`a'
>     + MG_b3*(h_Accountable*`a')
>     + MG_b4*h_Rivalry
>     + MG_b5*h_Borders
>     + MG_b6*h_Parliament
>     + MG_b7*h_Female 
>     + MG_b8*h_CivilWar
>     + MG_b9*h_GDPpc
>     + MG_b10*h_Growth
>     + MG_b11*h_MajorPower
>     + MG_b12*h_Mobilization
>     + MG_b13*h_Time 
>     + MG_b14*(h_Time^2)
>     + MG_b15*(h_Time^3)
>     + MG_b16*h_Constant;
 19. generate x_betahat1 = MG_b1* h_LameDuck
>     + MG_b2*`a'
>     + MG_b3*(h_LameDuck*`a')
>     + MG_b4*h_Rivalry
>     + MG_b5*h_Borders
>     + MG_b6*h_Parliament
>     + MG_b7*h_Female 
>     + MG_b8*h_CivilWar
>     + MG_b9*h_GDPpc
>     + MG_b10*h_Growth
>     + MG_b11*h_MajorPower
>     + MG_b12*h_Mobilization
>     + MG_b13*h_Time 
>     + MG_b14*(h_Time^2)
>     + MG_b15*(h_Time^3)
>     + MG_b16*h_Constant;
 20.  gen prob0=1/(1+exp(-x_betahat0));
 21. gen prob1=1/(1+exp(-x_betahat1));
 22.  gen diff0=prob1-prob0 ;
 23. egen probhat0=mean(prob0) ;
 24. egen probhat1=mean(prob1) ;
 25. egen diffhat0=mean(diff0) ;
 26. generate x_betahat01 =   MG_b1*h_Accountable
>     + MG_b2*`a'
>     + MG_b3*(h_Accountable*`a')
>     + MG_b4*h_Rivalry
>     + MG_b5*h_Borders
>     + MG_b6*h_Parliament
>     + MG_b7*h_Female 
>     + MG_b8*h_CivilWar
>     + MG_b9*h_GDPpc
>     + MG_b10*h_Growth
>     + MG_b11*h_MajorPower
>     + MG_b12*h_Mobilization
>     + MG_b13*h_Time 
>     + MG_b14*(h_Time^2)
>     + MG_b15*(h_Time^3)
>     + MG_b16*h_Constant;
 27.  generate x_betahat11 =   MG_b1* h_LameDuck
>     + MG_b2*`a'
>     + MG_b3*(h_LameDuck*`a')
>     + MG_b4*h_Rivalry
>     + MG_b5*h_Borders
>     + MG_b6*h_Parliament
>     + MG_b7*h_Female 
>     + MG_b8*h_CivilWar
>     + MG_b9*h_GDPpc
>     + MG_b10*h_Growth
>     + MG_b11*h_MajorPower
>     + MG_b12*h_Mobilization
>     + MG_b13*h_Time 
>     + MG_b14*(h_Time^2)
>     + MG_b15*(h_Time^3)
>     + MG_b16*h_Constant;
 28.   gen prob01=1/(1+exp(-x_betahat01));
 29. gen prob11=1/(1+exp(-x_betahat11));
 30. gen diff01=prob11-prob01 ;
 31. egen probhat01=mean(prob01) ;
 32. egen probhat11=mean(prob11) ;
 33. egen diffhat01=mean(diff01) ;
 34. gen delta=diff01-diff0;
 35. egen deltahat=mean(delta);
 36. tempname prob_hat0 lo0 hi0 prob_hat1 lo1 hi1 diff_hat0 diff_lo0 diff_hi0
>          prob_hat01 lo01 hi01 prob_hat11 lo11 hi11 diff_hat01 diff_lo01 diff_hi01
>          delta_hat delta_lo delta_hi;
 37.     _pctile prob0, p(2.5,97.5) ;
 38.     scalar `lo0'=r(r1) ;
 39.     scalar `hi0'=r(r2) ;
 40.     _pctile prob1, p(2.5,97.5) ;
 41.     scalar `lo1'=r(r1) ;
 42.     scalar `hi1'=r(r2) ;
 43.     _pctile diff0, p(2.5,97.5) ;
 44.     scalar `diff_lo0'= r(r1) ;
 45.     scalar `diff_hi0'=r(r2) ;
 46.     scalar `prob_hat0'=probhat0 ;
 47.     scalar `prob_hat1'=probhat1 ;
 48.     scalar `diff_hat0'=diffhat0 ;
 49.        _pctile prob01, p(2.5,97.5) ;
 50.     scalar `lo01'=r(r1) ;
 51.     scalar `hi01'=r(r2) ;
 52.     _pctile prob11, p(2.5,97.5) ;
 53.     scalar `lo11'=r(r1) ;
 54.     scalar `hi11'=r(r2) ;
 55.     _pctile diff01, p(2.5,97.5) ;
 56.     scalar `diff_lo01'= r(r1) ;
 57.     scalar `diff_hi01'=r(r2) ;
 58.     scalar `prob_hat01'=probhat01 ;
 59.     scalar `prob_hat11'=probhat11 ;
 60.     scalar `diff_hat01'=diffhat01 ;
 61.     _pctile delta, p(2.5,97.5) ;
 62.     scalar `delta_lo'= r(r1) ;
 63.     scalar `delta_hi'=r(r2) ;
 64.     scalar `delta_hat'=deltahat;
 65.     post mypost (`prob_hat0') (`lo0') (`hi0') (`prob_hat1') (`lo1') (`hi1') (`diff_hat0') (`diff_lo0') (`diff_hi0')
>                 (`prob_hat01') (`lo01') (`hi01') (`prob_hat11') (`lo11') (`hi11') (`diff_hat01') (`diff_lo01') (`diff_hi0
> 1')
>                 (`delta_hat') (`delta_lo') (`delta_hi')
> 
>     ;
 66.     } ;
 67.     drop    x_betahat0 x_betahat1 prob0 prob1 diff0 probhat0 probhat1 diffhat0
>             x_betahat01 x_betahat11 prob01 prob11 diff01 probhat01 probhat11 diffhat01
>             delta deltahat;
 68.     local a=`a'+ 1 ;
 69.     display "." _c ;
 70.     } ;
.....
. display "" ;


.  postclose mypost ;

. use PredictedValues, clear;

. sum;

    Variable |       Obs        Mean    Std. Dev.       Min        Max
-------------+--------------------------------------------------------
   prob_hat0 |         5    .0515367    .0107038   .0393646   .0663604
         lo0 |         5    .0306587    .0060993   .0214278   .0357742
         hi0 |         5     .080839    .0186918   .0662876   .1106635
   prob_hat1 |         5    .0348995    .0116086   .0232067   .0521958
         lo1 |         5    .0155045    .0039115   .0092512   .0191334
-------------+--------------------------------------------------------
         hi1 |         5    .0695826    .0347382   .0439489   .1273372
   diff_hat0 |         5   -.0166372      .00155  -.0180848  -.0141645
    diff_lo0 |         5   -.0480022    .0119114  -.0679849  -.0387569
    diff_hi0 |         5     .018469    .0236211   .0007654   .0585851
  prob_hat01 |         5    .0515367    .0107038   .0393646   .0663604
-------------+--------------------------------------------------------
        lo01 |         5    .0306587    .0060993   .0214278   .0357742
        hi01 |         5     .080839    .0186918   .0662876   .1106635
  prob_hat11 |         5    .0348995    .0116086   .0232067   .0521958
        lo11 |         5    .0155045    .0039115   .0092512   .0191334
        hi11 |         5    .0695826    .0347382   .0439489   .1273372
-------------+--------------------------------------------------------
  diff_hat01 |         5   -.0166372      .00155  -.0180848  -.0141645
   diff_lo01 |         5   -.0480022    .0119114  -.0679849  -.0387569
   diff_hi01 |         5     .018469    .0236211   .0007654   .0585851
   delta_hat |         5           0           0          0          0
    delta_lo |         5           0           0          0          0
-------------+--------------------------------------------------------
    delta_hi |         5           0           0          0          0

. gen ruler = _n;

. sum;

    Variable |       Obs        Mean    Std. Dev.       Min        Max
-------------+--------------------------------------------------------
   prob_hat0 |         5    .0515367    .0107038   .0393646   .0663604
         lo0 |         5    .0306587    .0060993   .0214278   .0357742
         hi0 |         5     .080839    .0186918   .0662876   .1106635
   prob_hat1 |         5    .0348995    .0116086   .0232067   .0521958
         lo1 |         5    .0155045    .0039115   .0092512   .0191334
-------------+--------------------------------------------------------
         hi1 |         5    .0695826    .0347382   .0439489   .1273372
   diff_hat0 |         5   -.0166372      .00155  -.0180848  -.0141645
    diff_lo0 |         5   -.0480022    .0119114  -.0679849  -.0387569
    diff_hi0 |         5     .018469    .0236211   .0007654   .0585851
  prob_hat01 |         5    .0515367    .0107038   .0393646   .0663604
-------------+--------------------------------------------------------
        lo01 |         5    .0306587    .0060993   .0214278   .0357742
        hi01 |         5     .080839    .0186918   .0662876   .1106635
  prob_hat11 |         5    .0348995    .0116086   .0232067   .0521958
        lo11 |         5    .0155045    .0039115   .0092512   .0191334
        hi11 |         5    .0695826    .0347382   .0439489   .1273372
-------------+--------------------------------------------------------
  diff_hat01 |         5   -.0166372      .00155  -.0180848  -.0141645
   diff_lo01 |         5   -.0480022    .0119114  -.0679849  -.0387569
   diff_hi01 |         5     .018469    .0236211   .0007654   .0585851
   delta_hat |         5           0           0          0          0
    delta_lo |         5           0           0          0          0
-------------+--------------------------------------------------------
    delta_hi |         5           0           0          0          0
       ruler |         5           3    1.581139          1          5

. saveold PredictedValues, replace;
file PredictedValues.dta saved

. 
end of do-file

. do "/var/folders/pp/9dcr80c13r9_24bby6f4sjrh0000gn/T//SD01417.000000"

. # delimit ;
delimiter now ;
. clear;

. *version 13;
. set matsize 400;

. set more off;

. log using "/Users/Jeff/Dropbox/TermLimits/Replication/Models/IndexEmpirical/Unconditional/Primary/PredictedValues.log", r
> eplace;
log file already open
r(604);

end of do-file

r(604);

. log close
      name:  <unnamed>
       log:  /Users/Jeff/Dropbox/TermLimits/Replication/Models/IndexEmpirical/Conditional/AdditionalControls/PredictedValue
> s.log
  log type:  text
 closed on:  12 Nov 2016, 21:01:58
---------------------------------------------------------------------------------------------------------------------------
